package com.honestpeak.datafusion.web;
import java.util.List;

import com.honestpeak.core.datasource.DataSourceContextHolder;
import com.honestpeak.core.datasource.DataSourceType;
import com.honestpeak.datafusion.common.ServerResponse;
import com.honestpeak.datafusion.service.PlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import com.honestpeak.datafusion.model.Department;
import com.honestpeak.datafusion.service.ClubMemberDistService;
import com.honestpeak.datafusion.service.DepartmentService;
/**
 * 平台数据
 */
@Controller
@RequestMapping("/platform")
public class PlatformController {
    @Autowired
    private PlatformService platformService;
	@Autowired
	private DepartmentService departmentService;
    @Autowired
    ClubMemberDistService clubMemberDistService;
	/**
	 * 平台数据下的今日数据
	 * @param mav
	 * @return
	 */
    @RequestMapping("/day")
    public ModelAndView Day(ModelAndView mav){
        mav.setViewName("platform/day");
        return mav;
    }
    /**
     * 平台数据下的数据比较
     * @param mav
     * @return
     */
    @RequestMapping("/databj")
    public ModelAndView DataBJ(ModelAndView mav){
    	List<Department> departList=departmentService.selectAll();
    	mav.addObject("departList",departList);
        List<String> yearList = clubMemberDistService.getYearTermInfo();
        mav.addObject("yearList", yearList);
        mav.setViewName("platform/databj");
        return mav;
    }

    /**
     * 今日活动人数
     * @return
     */
    @RequestMapping(value = "/todayActiveCount", method = RequestMethod.GET)
    @ResponseBody
    public Object todayActiveCount(){
        return platformService.getTodayActiveCount();
    }

    /**
     * 俱乐部今日活动人数
     * @return
     */
    @RequestMapping(value = "/todayClubActiveCount", method = RequestMethod.GET)
    @ResponseBody
    public Object todayClubActiveCount(){
        return platformService.getTodayClubActiveCount();
    }


    /**
     * 俱乐部今日活动排行榜
     * @return
     */
    @RequestMapping(value = "/todayClubActiveRanking", method = RequestMethod.GET)
    @ResponseBody
    public Object todayClubActiveRanking(){
        return platformService.getTodayClubActiveRanking();
    }


    /**
     * 数据比较，各系活动人数
     * @param departList
     * @return
     */
    @RequestMapping(value = "/getDataComparisons", method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse<Object> getDataComparisons(@RequestParam(value = "departList", required = false) List<String> departList,
                                                     @RequestParam(value = "year", required = false) String year){

        return platformService.getDataComparisons(departList, year);
    }
}